<template>
    <view class="content">
        <uni-list>
			<uni-list-item title="设置服务器路径" @click="toPath('../setPath/setPath')"></uni-list-item>
			<!-- <uni-list-item title="应用版本" :note="'当前应用版本：' + wgtVer" :show-badge="hasNewVer" badge-text="new" @click="getNowVersion"></uni-list-item> -->
		</uni-list>
    </view>
</template>

<script>
	import store from '@/vuex'
	import uniList from '@dcloudio/uni-ui/lib/uni-list/uni-list.vue'
	import uniListItem from '@dcloudio/uni-ui/lib/uni-list-item/uni-list-item.vue'
	import {checkUpdate} from '@/common/versionUpdate.js'
	
	export default {
		components: {
			uniList,
			uniListItem
		},
		data() {
			return {
				wgtVer:'无法获取版本号'
			}
		},
		computed:{
			latestVersion:{
				get () {
				  return store.getters.getLatestVersion
				},
				set (value) {
				  store.commit('updateLatestVersion', value)
				}
			},
			hasNewVer(){
				if(parseFloat(this.wgtVer) < parseFloat(this.latestVersion)){
					return true
				}else return false
			}
		},
		methods: {
			toPath(url){
				uni.navigateTo({
					url: url
				});
			},
			getNowVersion(){
				// #ifdef APP-PLUS
				checkUpdate({wgtVer:this.wgtVer,type:1})
				// #endif
			}
		},
        onReady() {
			// #ifdef APP-PLUS
			plus.runtime.getProperty(plus.runtime.appid,(inf)=>{// 获取应用版本号
				this.wgtVer = inf.version; 
				console.log("当前应用版本2：" + this.wgtVer);
				checkUpdate({wgtVer:this.wgtVer});//从服务器获取最新版本
			});
			// #endif
        }
	}
</script>

<style>
	
</style>
